<?php
App::uses('AppController', 'Controller');
/**
 * Contacts Controller
 *
 * @property Contact $Contact
 * @property PaginatorComponent $Paginator
 */
class ContactsController extends AppController {

/**
 * Components
 *
 * @var array
 */
	public $components = array('Paginator');

/**
 * index method
 *
 * @return void
 */
	public function index() {
		//$this->Contact->recursive = 0;
        //$this->set('contact', $this->Contact->find('first'));
		//$this->set('contacts', $this->Paginator->paginate());
	}
    
    public function send_email() {
        $data = $this->request->data;
        if ($this->request->is('post')) {
            App::uses('CakeEmail', 'Network/Email');
            $email = new CakeEmail('smtp');
            //$email = new CakeEmail('contact');
            $email->to($data['email']);
            $email->viewVars(array('data' => $data));
            $email->template('contact');
            $email->subject(__('Contact',true));
            if($email->send()) {
                $this->Session->setFlash(__('Your message has been submitted',true));
            } else {
                $this->Session->setFlash(__('Your message has been error',true));
            }
        }
        
        $this->redirect(array('action' => 'index'));
	}
}
